package com.slliver.service.impl;


import com.slliver.pojo.Product;
import com.slliver.service.ProductClientServcie;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class ProductClientServcieFallbackFactory implements FallbackFactory {
    @Override
    public Object create(Throwable throwable) {
        return new ProductClientServcie() {
            @Override
            public Product selectById(Long productId) {
                return new Product().setId(0).setTitle("服务降级的商品title").setImg("http://fuwujiangji.com/hystrix/product").setPrice(0.0).setNum(0);
            }

            @Override
            public List<Product> selectAll() {
                return new ArrayList<>();
            }
        };
    }
}
